#ifndef REGISTERWINDOW_H
#define REGISTERWINDOW_H
#include <QWidget>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QMessageBox>
#include <QPixmap>
#include <QFileDialog>

#include "../../DB/DbHandler.h"

namespace Ui {
class RegisterWindow;
}

class RegisterWindow : public QWidget
{
    Q_OBJECT

public:
    RegisterWindow(DbHandler* dbHandler, QWidget *parent = nullptr);
    ~RegisterWindow();

protected:
    void showEvent(QShowEvent *event) override;

signals:
    void registerSuccess(const QString &username);
    void backToLogin();

private slots:
    void on_pushButton_upload_clicked();
    void on_pushButton_confirm_clicked();
    void on_pushButton_back_clicked();

    void recvDbStatus(const QByteArray &status, quint16 userId);

private:
    Ui::RegisterWindow *ui;
    DbHandler* dbHandler;

    QString photoPath;
    
    void showStatus(const QString &message, bool isError = true);
    void clearStatus();
    bool validateInput();
    void saveUserInfo(const QString &username, const QString &realname, const QString &photoPath);
    bool hasCheckedGender();
};

#endif
